GXPD 25 - Using PICT Comments to Stretch and Rotate Objects
Title Banner


Technical Q&A's


GXPD 25 - Using PICT Comments to Stretch and Rotate Objects (1-July-95)


Q We are trying to add full GX-printing support to our drawing program, which isn't a GX-aware application, and we're running into some problems with the translator. When we use PICT comments to stretch and rotate objects, the objects sometimes disappear completely. Using direct GXRotateShape routines to rotate a shape has the same result. However, direct rotation and concatenation of the mappings works properly.

A This happens because support for flipping with picture comments was not included in the current implementation of GX. This will be fixed in a future release.

If you are using the translator, you're limited by the way it performs its translation. You would be better off providing your own replacement for the translator, because you understand your data structures better.

You can use the following code snippet as a starting point to create your own translator. It creates a GX Ink with a simple 8 x 8 black and white bit pattern, allows an arbitrary color for foreground and another for background, and can be added to a frame or fill:

//Code for calling SetShapeQDPattern()
			{
				char		pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
				RGBColor	fore, back;
				
				fore.red = 0xFFFF;
				fore.green = 0;
				fore.blue = 0;
				back.red = 0;
				back.green = 0xFFFF;
				back.blue = 0;
				
				SetShapeQDPattern(tempShape, (PatPtr)&pattern, &fore, &back);
			}
			
//SetShapeQDPattern()
// -------------------------------------------------------------------------------------
static void SetShapeQDPattern(
				gxShape theShape, 				// shape to set pattern on
				PatPtr pPattern, 				// 1 bit QD pattern to use
				RGBColor *pForeColor, 			// color of the 0 bits (or is this 1?)
				RGBColor *pBackColor)			// color of the 1 bits (or is this 0?)
{
	gxPatternRecord		pattern;
	gxBitmap			bits;
	gxSetColor			colors[2];
	
	pattern.attributes 	= 0;
	pattern.u.x			= ff(8);
	pattern.u.y			= ff(0);
	pattern.v.x			= ff(0);
	pattern.v.y			= ff(8);
	
	colors[0].rgb.red = pForeColor->red;
	colors[0].rgb.green = pForeColor->green;
	colors[0].rgb.blue = pForeColor->blue;
	colors[1].rgb.red = pBackColor->red;
	colors[1].rgb.green = pBackColor->green;
	colors[1].rgb.blue = pBackColor->blue;
	
	bits.image 		= (char*)pPattern;
	bits.width 		= 8;
	bits.height 	= 8;
	bits.rowBytes 	= 1;
	bits.pixelSize 	= 1;
	bits.space 		= gxIndexedSpace;
	bits.set 		= GXNewColorSet(gxRGBSpace, 2, &colors);
	bits.profile 	= nil;
	pattern.pattern	= GXNewBitmap(&bits, nil);
	GXDisposeColorSet(bits.set);
	
	GXSetShapePattern(theShape, &pattern);
	GXDisposeShape(pattern.pattern);
	
} // SetShapeQDPattern


//--------------------------------------------------


Technical Support
Technical Q&As
Previous Question | Contents | Next Question

Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help